<template>
    <rx-layout>
      <template v-slot:header>
        <rx-filters :isBpmClient="false"
                    :isMyBpm="isMyBpmClient"
                    :readType="readType"
                    :readKey="readKey"
                    :screenName="screenName"
                    :keyname="getTreeCatByList.key" :namelit="getTreeCatByList.name"
                    @loadListByParams="loadListByParams" :placeholder="i18n('inputTransfer','请输入转出待办名称')"></rx-filters>
      </template>
      <template v-slot:center>
        <rx-grid ref="rxGrid" :queryParam="queryParam" :url="'/api-bpm/bpm/core/bpmTaskTransfer/getMyTransOutTask'">
          <template v-slot:center="{record}">
              <view class="rx-center" @click="bpmDetails(record)">
                  <view class="rx-html" v-if="getStatusHtml(record.type)" v-html="getStatusHtml(record.type)"></view>
                  <view class="rx-createTime">
                      <my-icon style="color: rgba(66, 133, 244, 1);font-size: 1.2rem"
                               type="icon-linetime"></my-icon>
                      <view class="rx-createTime-name">{{record.createTime}}</view>
                  </view>
                  <view class="rx-top">
                      <view class="rx-icon-le"><view class="rx-icon_liucheng"><my-icon type="icon-Vue3jpaas-icon_liucheng"></my-icon></view></view>
                      <view class="rx-subject">{{ record.subject }}</view>
                  </view>
                  <view class="rx-operate" v-if="record.taskId">
                      <view class="rx-operate-button" @click.stop="retrieveTask(record)">
                          <my-icon type="icon-Vue3jpaas-icon_quhuirenwu"></my-icon>
                          {{ i18n('fetch', '取回') }}
                      </view>
                  </view>
              </view>
          </template>
        </rx-grid>
      </template>
    </rx-layout>
</template>

<script>
import RxGrid from '@/components/RxGrid'
import RxLayout from '@/components/RxLayout'
import RxFilters from '@/components/RxFilters'
import instAndTaskShareApi from "@/api/instAndTaskShareApi";
import getStatusHtml from '@/common/getStatusHtml.js'

export default {
  name: "RxMyTransOutTask",
  components: {RxGrid, RxLayout, RxFilters},
  mixins: [getStatusHtml],
  data() {
    return {
      isMyBpmClient: true,
      readKey: "task.read",
      readType: "transOutTask",
      isInit: true,
      getTreeCatByList: '',
      queryParam: {},//筛选参数
      screenName: 'SUBJECT'
    }
  },

  created() {
    this.getTreeCatByKey()
  },
    onShow(){
        if(this.$refs.rxGrid){
            this.$refs.rxGrid.getInit(true, true);
        }
    },
  methods: {
    i18n(name, text, key) {
      return this.$ti18(name, text, "bpmLang", key);
    },
    getTreeCatByKey() {
      instAndTaskShareApi.getTreeCatByKey().then(ret => {
        this.getTreeCatByList = ret;
      })
    },
    //筛选
    loadListByParams(params) {
      this.queryParam = params
    },
    bpmDetails(obj) {
      let params = {
        instId: obj.instId,
        routerName: 'openDoc',
        action: 'detail'
      }
        let mobileAppId = uni.getStorageSync("mobileAppId");
        let appId =''
        if(obj.appId){
            appId=obj.appId?obj.appId:mobileAppId
        }
      uni.navigateTo({
        url: '/views/modules/bpm/OpenDoc?params=' + JSON.stringify(params)+'&appId='+appId
      })
    },
    /*
    取回
     */
    retrieveTask(record) {
      let data = {
        taskId: record.taskId,
        subject: record.subject,
      }
      let url ='/views/modules/bpm/task/BpmRetrieveTask';
      url = url+'?data='+JSON.stringify(data)
      uni.navigateTo({url:url})
    },
  }
}
</script>

<style scoped>
@import "../RxProcessManagement.css";
</style>
